package ontology;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.List;
import java.util.ArrayList;

/**
 * This class is used to parse the 'frame-relation-type' elements
 * of the relations file (frXML/frRelation.xml) in the FrameNet ontology.
 * These elements have the following format:
 * 
 * frame-relation-type @name
 *   > frame-relations
 *       > frame-relation*   [aka. links between types/frames]
 *
 */

public class FrameRelationType {

	public String name;
	public List<FrameRelation> links = new ArrayList<FrameRelation>();
	
	public FrameRelationType(Element e) {
		name = e.getAttribute("name");
		NodeList ns = e.getChildNodes();
		for (int i=0;i<ns.getLength();i++) {
			Node n = ns.item(i);
			String s = n.getNodeName();
			if (s.equals("frame-relations")) {
				NodeList nns = ((Element) n).getChildNodes();
				for (int j=0;j<nns.getLength();j++) {
					Node nn = nns.item(j);
					String ss = nn.getNodeName();
					if (ss.equals("frame-relation")) {
						links.add(new FrameRelation((Element) nn));
					}
				}				
			}
		}
	}
	
}
